<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <title>Egret3D Examples</title>
    <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="full-screen" content="true" />
    <meta name="screen-orientation" content="portrait" />
    <meta name="x5-fullscreen" content="true" />
    <meta name="360-fullscreen" content="true" />
    <style>
        html,
        body {
            overflow: hidden;
            background: #000000;
            padding: 0;
            border: 0;
            margin: 0;
            height: 100%;
            touch-action: none;
        }
    </style>
    <script type="text/javascript" src="https://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/3.0.0/vconsole.min.js"></script>
</head>

<body onContextMenu="return false">
    <div 
        style="margin: auto;width: 100%;height: 100%;overflow: hidden;" 
        class="egret-player" 
        data-entry="main"
        data-scene=""
        data-tick-rate="auto"
        data-frame-rate="auto"
        data-content-width="1136"
        data-content-height="640"
        data-antialias="true"
        data-alpha="false"

        data-orientation="auto"
        data-scale-mode="showAll"
        data-multi-fingered="2"
        
        data-show-stats="true"
        data-show-inspector="auto"
        >
    </div>

    <script>
        
        var loadScript = function (list, callback) {
            var loaded = 0;
            var loadNext = function () {
                loadSingleScript(list[loaded], function () {
                    loaded++;
                    if (loaded >= list.length) {
                        callback();
                    }
                    else {
                        loadNext();
                    }
                })
            };
            loadNext();
        };

        var loadSingleScript = function (src, callback) {
            var s = document.createElement('script');
            s.async = false;
            s.src = src;
            s.addEventListener('load', function () {
                s.parentNode.removeChild(s);
                s.removeEventListener('load', arguments.callee, false);
                callback();
            }, false);
            document.body.appendChild(s);
        };

        var xhr = new XMLHttpRequest();
        xhr.open('GET', './manifest.json?v=' + Math.random(), true);
        xhr.addEventListener("load", function () {
            var manifest = JSON.parse(xhr.response);
            var list = manifest.initial.concat(manifest.game);
            loadScript(list, function () {
                egret3d.runEgret();
                /**
                 * `paper.Application.pause(); // 如果是编辑器模式, egret3d.runEgret() 之后即可暂停主循环`
                 */
            });
        });
        xhr.send(null);

        /**
         * 运行时设置帧频和暂停/恢复
         * 
        ```js
        var paused = true;
        var tps = 10;
        var fps = 15;
        var firstResume = true;
        window.ondblclick = () => {
            paused = !paused;

            if (!paused && !firstResume) {
                // 运行时修改逻辑帧频
                paper.clock.tickInterval = 1.0 / tps;
                tps += 10;
                if (tps > 70) { tps = 10; }

                // 运行时修改渲染帧频
                paper.clock.frameInterval = 1.0 / fps;
                fps *= 2;
                if (fps > 60) { fps = 15; }
            }

            // 运行时切换主动(主循环运行)和被动刷新(主循环暂停)
            if (paused) {
                paper.Application.pause();
             } else {
                paper.Application.resume();
                firstResume = false;
            }
        }
        ```
         */
    </script>
</body>

</html>